package com.rxt.controller;

import com.rxt.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@Api(tags = "测试")
@RequestMapping("/test")
public class TestController {

    @ApiOperation("测试接口1")
    @GetMapping("/{num}")
    public Result test1(@PathVariable int num, HttpSession session) {
        session.setAttribute("num", num);
        return Result.ok("测试接口..." + num);
    }

    @ApiOperation("测试接口2")
    @GetMapping
    public Result test2(HttpSession session) {
        Integer num = (Integer) session.getAttribute("num");
        System.out.println(num);
        return Result.ok();
    }
}
